﻿using AutoUpdateTools.Models;
using MessageServer.Update;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoUpdateTools
{

    public class GlobalInfo
    {
        

        public static List<PackageUpdateModel> UpdateHostFiles = new List<PackageUpdateModel>();

        /// <summary>
        /// 网站包信息
        /// </summary>
        public static List<PackageInfoEntity> WebPackageInfo = new List<PackageInfoEntity>();



        public static void Init()
        {
            
            //获取所有的更新包信息
            GlobalInfo.WebPackageInfo = new UpdateThread().GetAllPackageInfo(); 

            StreamReader sr = new StreamReader("updatefile.json");
            string content = sr.ReadToEnd(); 
            var lst = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PackageUpdateModel>>(content);
            //更新宿主文件
            GlobalInfo.UpdateHostFiles = lst;
        }
    }
   
}
